<template>
	<view>
		<cu-custom bgColor="bg-black" :isBack="true">
			<block slot="backText">返回</block>
			<block slot="content">我的帖子</block>
		</cu-custom>
		<!-- 	<view class="nav">
			<scroll-view scroll-x class="bg-white nav">
				<view class="flex text-center">
					<view class="cu-item flex-sub" :class="index==TabCur?'text-orange cur':''" v-for="(item,index) in list" :key="index"
					 @tap="tabSelect" :data-id="index">
						{{item}}
					</view>
				</view>
			</scroll-view>
		</view> -->
		<view class="cu-list menu-avatar" v-if="dataList.length!=0">
			<view class="cu-item" v-for="item in dataList" :key='item.id' @click="handChekDetails(item.orderId)">
				<view class="cu-avatar round lg" :style="{backgroundImage:'url('+ item.handlUrl +')'}"></view>
				<view class="content">
					<view class="text-grey">{{item.nickName}}</view>
					<view class="text-gray text-sm flex">
						<view class="text-cut">
							{{item.content}}
						</view>
					</view>
				</view>
			</view>
		</view>
		<view style="text-align: center;" v-else>
				<image src="../../../static/img-no-data.png" style="width: 320upx;
		height: 320upx;margin: 200upx auto;" mode=""></image>
			</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				TabCur: 0,
				scrollLeft: 0,
				list: ['已回复', '未回复', '已解决', '全部'],
				dataList: [],
				page: 1,
				per_page: 10,
				userMsg: {}
			};
		},
		onLoad() {

			if (uni.getStorageSync('USER')) {
				this.userMsg = JSON.parse(uni.getStorageSync('USER'))
			}
			this.getMore()
			console.log(this.userMsg)
		},
		async onReachBottom() {
			this.loadMore()
		},
		async onPullDownRefresh() {
			this.getMore()
		},
		methods: {
			handChekDetails(id) {
				uni.navigateTo({
					url: '/pages/home/entrustDetails/entrustDetails?id=' + id,
					fail: function(err) {
						console.info("跳转失败", err)
					}
				})
				console.log('ww')
			},
			tabSelect(e) {
				this.TabCur = e.currentTarget.dataset.id;
				this.scrollLeft = (e.currentTarget.dataset.id - 1) * 60
			},
			async loadMore() {
				console.log('加载更多')
				uni.showLoading({
					title: '加载中...',
					icon: 'none'
				})
				let page = this.page
				let per_page = this.per_page
				let dataList = this.dataList
				page++;
				let dataListNextPage = await this.http.findYuUserNoticByPage({
					page,
					limit: per_page,
					parentId: 0,
					userId: this.userMsg.id
				});
				uni.hideLoading()
				this.dataList = [...dataList, ...dataListNextPage];
				if (dataListNextPage.length) {
					this.page = page;
				};
				if (!dataListNextPage.length) {
					this.print('没有更多了')
				}

			},
			async getMore() {
				this.page = 1
				let newObj = {
					page: this.page,
					limit: this.per_page,
					parentId: 0,
					userId: this.userMsg.id
				}
				let dataList = await this.http.findYuUserNoticByPage(newObj);
				this.dataList = dataList
				console.log(this.dataList, 'this.dataList')
			},
		}
	}
</script>

<style>
</style>
